//
//  MXHomePageCell.m
//  MXUserSys
//
//  Created by 王启颖 on 2018/10/10.
//  Copyright © 2018年 王启颖. All rights reserved.
//

#import "MXHomePageCell.h"

@interface MXHomePageCell ()
@property (weak, nonatomic) IBOutlet UILabel *price;
@property (weak, nonatomic) IBOutlet UILabel *total_production;
@property (weak, nonatomic) IBOutlet UIImageView *beltPic;
@property (weak, nonatomic) IBOutlet UILabel *createDate;
@property (weak, nonatomic) IBOutlet UILabel *manufactor;
@property (weak, nonatomic) IBOutlet UILabel *needleNum;
@end

@implementation MXHomePageCell

-(void)setModel:(MXHomePageModel *)model{
    _model = model;
    self.price.text = model.price;
    self.total_production.text = model.total_production;
    self.needleNum.text = model.style;
    self.createDate.text = [[model.create_time substringToIndex:model.create_time.length - 3] changeToDateWithDateFormatter:@"YYYY-MM-dd hh:mm"];
    
    [self.beltPic sd_setImageWithURL:[NSURL URLWithString:model.belt_pic] placeholderImage:[UIImage imageNamed:@"photoAndVideoDefault"]];
    
    [[MXAccount sharedMXAccount] LoadManufactorFromSandbox];
    NSArray *manufactorArr = [MXAccount sharedMXAccount].manufactorArr;

    for (int i = 0; i<manufactorArr.count; i++) {
        NSDictionary *dic = manufactorArr[i];
        NSString *name = dic[@"manufactor_name"];
        NSNumber *id = dic[@"manufactor_id"];
        if ([model.manufactor_id isEqualToString:[id stringValue]]) {
            self.manufactor.text = name;
        }
        
    }
    
    
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

+ (instancetype)cellWithTableView:(UITableView *)tableView {
    
    MXHomePageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = NSbunleloadNibName(@"MXHomePageCell");
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
    
    return cell;
}

@end
